<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset=utf-8>
</head>

<body>
    <h1>WebSockets Load Test</h1>
    <p>Doing infinite WS load test ...</p>
    <script>

    function test() {
        ws = new WebSocket('ws://localhost:4100/websockets/basic/echo', ['chat']);

        //  TODO - can't send here until handshake received
        // ws.send(JSON.stringify('Hello WebSockets World'));

        ws.onopen = function (event) {
            console.log("OPEN");
            ws.send("Thanks for opening");
            console.log(event.data);
        };
        ws.onmessage = function (event) {
            console.log("MSG", event.data);
            ws.close();
        };
        ws.onclose = function (event) {
            console.log("CLOSED");
            test();
        };
        ws.onerror = function (event) {
            console.log("Error " + event);
        };
    }
    test();
    </script>
</body>
</html>
